﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;

namespace IP
{
    class Program
    {
        static void Main(string[] args)
        {
            ///获取本机电脑名
            var userName = System.Net.Dns.GetHostName();
            Console.WriteLine(userName);
            ///通过电脑名获取本机IP
            var ip = System.Net.Dns.Resolve(userName).AddressList;

            Console.WriteLine(ip[0].ToString());
            Console.ReadKey();
        }
    }
}
